<?php


namespace app\oa\controller;


use cmf\controller\HomeBaseController;
use think\Db;
use think\db\exception\DataNotFoundException;
use think\db\exception\ModelNotFoundException;
use think\exception\DbException;

class HasController extends HomeBaseController
{
    public function index()
    {
        $user = cmf_get_current_admin_id();
        $data = Db::name('oa_local')->where(['user' =>$user])->order('date desc')->select()->toArray();
        foreach ($data as $k => &$v) {
            $v['lname'] =Db::name('engine')->where(['id'=>$v['eid']])->value('name');
        }
        $this->assign('data',$data);
        return $this->fetch();

    }

    /**
     * 查看详情
     * @return mixed|string
     * @throws DataNotFoundException
     * @throws DbException
     * @throws ModelNotFoundException
     */
    public function see()
    {
        $data = $this->request->param();
        $res = Db::name('oa_local')->where(['id' => $data['id']])->find();
        $res['imgs'] = explode(',', $res['imgs']);
        foreach ($res['imgs'] as $k => &$v) {
            $v = 'http://' . $_SERVER['SERVER_NAME'] . $v;
        }
        $res['lname'] = Db::name('engine')->where(['id' => $res['eid']])->value('name');
        $setd = Db::name('engine')->field('id,name')->select();
        $this->assign('setd', $setd);
        $this->assign('res', $res);
        return $this->fetch();
    }
}